package com.nostra13.sample.base;


import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.agp.window.dialog.ToastDialog;
import ohos.bundle.IBundleManager;
import ohos.global.systemres.ResourceTable;

/**
 * ================================================
 * 作    者：jeasonlzy（廖子尧 Github地址：https://github.com/jeasonlzy0216
 * 版    本：1.0
 * 创建日期：2016/5/19
 * 描    述：
 * 修订历史：
 * ================================================
 */
public class ImageBaseActivity extends Ability {

    private ToastDialog dialog;

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);

//        tintManager = new SystemBarTintManager(this);
//        tintManager.setStatusBarTintEnabled(true);
//        tintManager.setStatusBarTintResource(ResourceTable.Color_ip_color_primary_dark);  //设置上方状态栏的颜色
//        getWindow().setStatusBarColor(ResourceTable.Color_ip_color_primary_dark);
    }

//    @Override
//    protected void onCreate(Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
//            setTranslucentStatus(true);
//        }
//
//    }

//    @TargetApi(19)
//    private void setTranslucentStatus(boolean on) {
//        Window win = getWindow();
//        WindowManager.LayoutConfig winParams = win.getAttributes();
//        final int bits = WindowManager.LayoutConfig.FLAG_TRANSLUCENT_STATUS;
//        if (on) {
//            winParams.flags |= bits;
//        } else {
//            winParams.flags &= ~bits;
//        }
//        win.setAttributes(winParams);
//    }

    public boolean checkPermission(String permission) {
        return verifySelfPermission(permission) == IBundleManager.PERMISSION_GRANTED;
    }

    public void showToast(String toastText) {
        if (dialog == null) {
            dialog = new ToastDialog(this);
        }
        if (dialog.isShowing()) {
            dialog.hide();
        }
        dialog.setText(toastText);
        dialog.setDuration(2_000);

        dialog.show();
    }

//    @Override
//    protected void onRestoreInstanceState(Bundle savedInstanceState) {
//        super.onRestoreInstanceState(savedInstanceState);
//        ImagePicker.getInstance().restoreInstanceState(savedInstanceState);
//    }
//
//    @Override
//    protected void onSaveInstanceState(Bundle outState) {
//        super.onSaveInstanceState(outState);
//        ImagePicker.getInstance().saveInstanceState(outState);
//    }
}
